package com.gexiaobao.pigeon.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.ThematicListBean
import com.gexiaobao.pigeon.app.util.DatetimeUtil
import com.gexiaobao.pigeon.app.util.ImageLoaderManager
import com.gexiaobao.pigeon.databinding.ItemThematicListBinding
import com.makeramen.roundedimageview.RoundedImageView

/**
 * @Author      : hxw
 * @Date        : 2024/11/12 15:53
 * @Describe    :
 */
class AdapterThematicList(data: ArrayList<ThematicListBean>) :
    BaseQuickAdapter<ThematicListBean, DataBindBaseViewHolder>(R.layout.item_thematic_list, data) {

    override fun convert(holder: DataBindBaseViewHolder, item: ThematicListBean) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemThematicListBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        holder.setGone(R.id.ivProxyPriceState, item.proxyId == 0)

        val closeTime = DatetimeUtil.stringToDate(item.endTime)
        holder.setText(R.id.tvCloseAuctionTime, closeTime + "结拍")

        val ivThematicImage = holder.getView<RoundedImageView>(R.id.ivThematicImage)
        ImageLoaderManager.loadRoundImage(context, item.firstImgThumbnailUrl, ivThematicImage, 6)
    }
}